package com.flats.service.transactional;

import com.flats.model.dao.Dao;
import com.flats.model.entity.Comment;
import com.flats.service.CommentService;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

@Transactional
public class TransactionalCommentService implements CommentService {
    private Dao<Comment> commentDao;

    public void setCommentDao(Dao<Comment> commentDao) {
        this.commentDao = commentDao;
    }

    @Override
    @Transactional
    public Serializable saveOrUpdate(Comment persistent) {
        return commentDao.saveOrUpdate(persistent);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        commentDao.delete(id);
    }

    @Override
    @Transactional
    public void delete(Comment persistent) {
        commentDao.delete(persistent);
    }

    @Override
    @Transactional
    public Comment get(Long id) {
        return commentDao.get(id);
    }

    @Override
    @Transactional
    public List<Comment> getAll() {
        return commentDao.getAll();
    }
}
